home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / fortran / peekpo.com / README.DOC < prev   
Encoding:
Text File  |  1990-10-16  |  7.3 KB  |  149 lines

  1.                       DIRECT VIDEO I/O IN FORTRAN
  2.  
  3.      The inter-language calling facilities of the Lahey and  Microsoft
  4. Fortran compilers make it is possible to perform  direct  I/O  to  any
  5. location in memory, including the display adapters.  In essence,  they
  6. provide a PEEK/POKE facility  without  the  overhead  associated  with
  7. making a subroutine call for each character.
  8.  
  9.      PUTL.FOR shows a main program, and  PUT2.FOR  a  subroutine  that
  10. will write three short pieces of text to a color monitor.   The  first
  11. character string will be in ordinary white on  black,  the  second  in
  12. bold white on blue, and the third in flashing yellow on blue.
  13.  
  14.      You can generate PUTL.EXE using the batch file PL.BAT, which will
  15. call the Lahey compiler and linker to create a runnable unit.
  16.  
  17.      This program uses Lahey F77L's CARG function, which transmits the
  18. value of its argument to the subroutine, rather than its address.  The
  19. subroutine, PUT_IT, however thinks that it is being passed the address
  20. of an array, which it is to write in.  What appears to be the  address
  21. of the array SCREEN is actually a constant data item pointing  to  the
  22. address of the color text area of a PC's memory.  (In order  to  write
  23. to a monochrome adapter, the  value  B8000000  should  be  changed  to
  24. B0000000.)
  25.  
  26.      PUTM.FOR is an alternate main program, set  up  to  do  the  same
  27. thing using Microsoft's compiler.   The  differences  from  the  Lahey
  28. version are: 1) the addition of an INTERFACE statement which specifies
  29. that the first argument to PUT_IT is to be passed by value, and 2) the
  30. format for expressing a hexadecimal number when ICRT is given a value.
  31. Subroutine PUT_IT is not listed, as it is identical with the  previous
  32. version, and we can use the one in file PUT2.FOR again (as long as  it
  33. is recompiled with the MS compiler!).
  34.  
  35.      You can generate PUTM.EXE by using the batch file  PM.BAT,  which
  36. invokes compiler and linker.
  37.  
  38.      Microsoft Fortran will  issue  a  warning  message  if  the  main
  39. program and the subroutine are compiled in one file, as it will detect
  40. the disagreement in the argument lists.  This is why PUT_IT is sitting
  41. in a file by itself: so that the compiler can not figure out  what  we
  42. are doing.
  43.  
  44.      The same tricks can be used to read data back  from  the  screen.
  45. GETL.FOR contains an F77L program that will read  40  characters  from
  46. the video adapter, starting at column 5, line 10.  (These numbers  are
  47. arbitrary - you can see where they are being passed  as  arguments  to
  48. GET_IT.)  Subroutine GET_IT, which is in file GET2.FOR, strips off the
  49. graphic attribute  byte  and  stores  the  plain  character  into  the
  50. CHARACTER variable that is passed to it.  GETM.FOR is  the  same  main
  51. program,  but  written  for  the  Microsoft  compiler;    again,   the
  52. subroutine GET_IT is identical to that used with F77L.
  53.  
  54.      To generate the screen reading programs, use either  GL.BAT  (for
  55. Lahey) or GM.BAT (for Microsoft).
  56.  
  57.  
  58.                                   1
  59.                                                                 PAGE 2
  60.  
  61.  
  62.      A few subroutines using these techniques can form the  basis  for
  63. some simple pop-up windows, without the need for assembly language  or
  64. third-party packages.  When it is necessary for a window to appear  on
  65. the screen, the needed area (both characters and  attributes)  can  be
  66. read and stored into an array.  The new box  can  be  written  to  the
  67. screen, and then, when it is to disappear, the  original  contents  of
  68. that region can be restored from the array.
  69.  
  70.      Many  varieties  of  personal  computer  can  be  identified   by
  71. examining the System ID Byte,  which  is  stored  at  FFFF:000E.   For
  72. example, a real IBM AT has "FC" (hex) stored there.  Two programs  are
  73. provided (one for use with each compiler) to read and report the value
  74. of this byte: for Lahey, the file is MACHIDL.FOR, and for Microsoft it
  75. is MACHIDM.FOR.
  76.  
  77.      Note that the Microsoft compiler will complain about an  argument
  78. mismatch when calling PEEKB0 - this is because it has figured out that
  79. we are passing the first argument (the address)  by  value,  and  then
  80. using it to read by reference inside the subroutine.  If this  bothers
  81. you (personally, I prefer to have ALL the  error  messages  go  away),
  82. then you can deprive the compiler of the information that is necessary
  83. to identify this condition by compiling PEEKB0 separately, as  we  did
  84. with GET_IT and PUT_IT.
  85.  
  86.      After examining how these programs work, you should  be  able  to
  87. create your own PEEK and POKE routines whenever they are needed.
  88.  
  89.      If these files are useful to you, DO NOT send money  -  a  simple
  90. "thank you" would be appropriate.  Also, find  something  that  others
  91. (like me) would find useful, and post it on this bulletin board.  And,
  92. do it in Fortran, not "C" - so that grownups can use it.
  93.  
  94.  
  95.                     Kenneth G. Hamilton, Ph.D.
  96.                     P.  O.  Box 9388
  97.                     San Diego CA 92169-0388
  98.                     CompuServe [72727,177]
  99.                     GEnie K.HAMILTON3
  100.  
  101.          ----------------end-of-author's-documentation---------------
  102.  
  103.                          Software Library Information:
  104.  
  105.                     This disk copy provided as a service of
  106.  
  107.                            Public (software) Library
  108.  
  109.          We are not the authors of this program, nor are we associated
  110.          with the author in any way other than as a distributor of the
  111.          program in accordance with the author's terms of distribution.
  112.  
  113.          Please direct shareware payments and specific questions about
  114.          this program to the author of the program, whose name appears
  115.          elsewhere in  this documentation. If you have trouble getting
  116.          in touch with the author,  we will do whatever we can to help
  117.          you with your questions. All programs have been tested and do
  118.          run.  To report problems,  please use the form that is in the
  119.          file PROBLEM.DOC on many of our disks or in other written for-
  120.          mat with screen printouts, if possible.  PsL cannot debug pro-
  121.          programs over the telephone, though we can answer questions.
  122.  
  123.          Disks in the PsL are updated  monthly,  so if you did not get
  124.          this disk directly from the PsL, you should be aware that the
  125.          files in this set may no longer be the current versions. Also,
  126.          if you got this disk from another vendor and are having prob-
  127.          lems,  be aware that  some files may have become corrupted or
  128.          lost by that vendor. Get a current, working disk from PsL.
  129.  
  130.          For a copy of the latest monthly software library newsletter
  131.          and a list of the 2,000+ disks in the library, call or write
  132.  
  133.                            Public (software) Library
  134.                                P.O.Box 35705 - F
  135.                             Houston, TX 77235-5705
  136.  
  137.                                  Orders only:
  138.                                 1-800-2424-PSL
  139.                               MC/Visa/AmEx/Discover
  140.  
  141.                           Outside of U.S. or in Texas
  142.                           or for general information,
  143.                               Call 1-713-524-6394
  144.  
  145.                           PsL also has an outstanding
  146.                           catalog for the Macintosh.
  147.  
  148.  
  149.